class Calculator(var value1: Double, var value2: Double, var value3: Double) {

  // 加法和乘法的混合运算
  def additionAndMultiplication(): Double = {
    value1 + value2 * value3
  }

  // 乘除法运算
  def multiplicationAndDivision(): Double = {
    if (value3 != 0) {
      value1 * value2 / value3
    } else {
      println("除数不能为0")
      0
    }
  }
}
object t1 {
  def main(args: Array[String]): Unit = {
    // 从控制台输入三个值
    println("请输入第一个值: ")
    val value1 = scala.io.StdIn.readDouble()

    println("请输入第二个值: ")
    val value2 = scala.io.StdIn.readDouble()

    println("请输入第三个值: ")
    val value3 = scala.io.StdIn.readDouble()

    // 实例化 Calculator 类
    val calc = new Calculator(value1, value2, value3)

    // 执行加法和乘法混合运算
    val result1 = calc.additionAndMultiplication()
    println(s"加法和乘法的混合运算结果是: $result1")

    // 执行乘除法运算
    val result2 = calc.multiplicationAndDivision()
    println(s"乘除法运算结果是: $result2")
  }
}
